Depending on the type of product you are using, the definitions of ‘Parameter’, ‘IO Logic’, ‘AxisStatus’, etc. may be different.
This example is based on ‘Ezi-SERVO2’, so please apply the appropriate value depending on the product you are using.
Example)
FM_EZISERVO2_PARAM // Parameter enum when using 'Ezi-SERVO2' 'Ezi-SERVO2'
FM_EZIMOTIONLINK2_PARAM // Parameter enum when using 'Ezi-MOTIONLINK2'
[EN]
1. Connect a device. 2. Get product information. 3. Close connection.
[KR]
1. 장치 연결. 2. 제품 종류 확인. 3. 연결 해제.
bool Connect(int nCommType, int nBdID)
{unsigned char byIP[4] = { 192, 168, 0, 2 }; // IP : 192.168.0.2
bool bSuccess = true;
// Connection
switch (nCommType)
{case TCP:
// TCP Connection
if (FAS_ConnectTCP(byIP[0], byIP[1], byIP[2], byIP[3], nBdID) == 0)
{"TCP Connection Fail! \n");
printf(false;
bSuccess =
}break;
case UDP:
// UDP Connection
if (FAS_Connect(byIP[0], byIP[1], byIP[2], byIP[3], nBdID) == 0)
{"UDP Connection Fail! \n");
printf(false;
bSuccess =
}break;
default:
"Wrong communication type. \n");
printf(false;
bSuccess =
break;
}
if (bSuccess)
"Connected successfully. \n");
printf(
return bSuccess;
}
[EN]
‘FAS_Connect’ is a function for UDP connection, and ‘FAS_ConnectTCP’ is a function for TCP connection. If the function returns ‘TRUE’, the connection is successful.
[KR]
’FAS_Connect’는 UDP 연결을, ’FAS_ConnectTCP’는 TCP 연결을 하는 함수입니다. 함수가 ’TRUE’를 리턴하면 연결이 성공한 것입니다.
bool CheckDriveInfo(int nBdID)
{unsigned char byType = 0;
char IpBuff[256] = "";
int nBuffSize = 256;
int nRtn;
// Read Drive's information
nRtn = FAS_GetSlaveInfo(nBdID, &byType, IpBuff, nBuffSize);if (nRtn != FMM_OK)
{"Function(FAS_GetSlaveInfo) was failed.\n");
printf(return false;
}
"Board ID %d : TYPE= %d, Version= %s\n", nBdID, byType, IpBuff);
printf(
return true;
}
[EN]
After successful connection, a function ‘FAS_GetSlaveInfo’ was used to check product information. This function is not required for connection, but to just show an example of using a function after successful connection.
[KR]
연결 성공 후 제품의 정보를 확인하는 함수(FAS_GetSlaveInfo)를 사용하였습니다. 이 함수는 연결에 필요한 함수가 아닙니다. 연결 후 임의의 함수를 호출한 것입니다.
// Connection Close
FAS_Close(nBdID);
[EN]
Use ‘FAS_Close’ to close the connection.
[KR]
’FAS_Close()’를 통해 연결을 해제할 수 있습니다.